package mn.more.mock.gen;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @author $Author: mikeliucc $
 * @version $Revision: 119 $
 */
public class FractionGenerator extends GeneratorBase {

	private int maxBase;

	public int getMaxBase() { return maxBase; }

	public void setMaxBase(int maxBase) { this.maxBase = maxBase; }

	public List<String> generate() throws IOException {
		List<String> numbers = new ArrayList<String>(max);

		Random rand = new Random(System.currentTimeMillis());
		for (int i = 0; i < max; i++) {
			String fraction = rand.nextInt(maxBase) + "/" + maxBase;
			if (isDataUsable(numbers, fraction)) {
				numbers.add(fraction);
			} else {
				i--;
			}
		}

		return numbers;
	}
}
